package com.xdwanj.service.impl;

import com.xdwanj.dao.PetDao;
import com.xdwanj.dao.impl.PetDaoImpl;
import com.xdwanj.pojo.Pet;
import com.xdwanj.service.PetService;
import com.xdwanj.util.PageBean;

public class PetServiceImpl implements PetService {
    PetDao petDao = new PetDaoImpl();

    @Override
    public PageBean<Pet> findPetList() {
        return null;
    }

    @Override
    public boolean delPet(int pid) {
        try {
            petDao.deletePet(pid);
            return true;
        } catch (Exception e) {
            e.printStackTrace();
        }
        return false;
    }

    @Override
    public boolean addPet(int uid, Pet pet) {
        try {
            petDao.addPet(uid, pet);
            return true;
        } catch (Exception e) {
            e.printStackTrace();
        }
        return false;
    }

    @Override
    public boolean updatePet(Pet pet) {
        try {
            petDao.updatePet(pet);
            return true;
        } catch (Exception e) {
            e.printStackTrace();
        }
        return false;
    }

    @Override
    public PageBean<Pet> findPetAllList() {
        PageBean<Pet> customerPageDto = null;
        try {
            customerPageDto = petDao.findAll();
        } catch (Exception e) {
            e.printStackTrace();
        }
        return customerPageDto;
    }

    @Override
    public PageBean<Pet> findPetByName(String name, int pageSize, int currentPageNo) {
        PageBean<Pet> customerPageDto = null;
        try {
            customerPageDto = petDao.findPetListByName(name, pageSize, currentPageNo);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return customerPageDto;
    }


}
